use thiserror::Error;

#[derive(Error, Debug)]
pub enum ModbusCollectorError {
    #[error("Configuration error: {0}")]
    Config(String),
    
    #[error("Modbus communication error: {0}")]
    Modbus(#[from] tokio_modbus::Error),
    
    #[error("Excel parsing error: {0}")]
    Excel(#[from] calamine::Error),
    
    #[error("Storage error: {0}")]
    Storage(String),
    
    #[error("API error: {0}")]
    Api(String),
    
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),
    
    #[error("Serialization error: {0}")]
    Serde(#[from] serde_json::Error),
    
    #[error("Redis error: {0}")]
    Redis(#[from] redis::RedisError),
    
    #[error("File watch error: {0}")]
    FileWatch(#[from] notify::Error),
    
    #[error("Other error: {0}")]
    Other(#[from] anyhow::Error),
}

pub type Result<T> = std::result::Result<T, ModbusCollectorError>;